sysroot: Drop an unnecessary fsync
authorColin Walters <walters@verbum.org>
Wed, 14 Sep 2016 00:38:21 +0000 (20:38 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Wed, 14 Sep 2016 19:14:46 +0000 (19:14 +0000)
While looking at a slow update issue (which I'm guessing is
unpredictable I/O latency in an OpenStack instance), I noticed
in one of the traces we were inside a fsync here.

Dropping the fsync here is just another of a long series of unwinding
them - we `syncfs()` the sysroot fd and `/boot` and we have a big
`sync()` anyways.

Closes: #508
Approved by: jlebon

src/libostree/ostree-sysroot-deploy.c
src/libotutil/ot-gio-utils.c
src/libotutil/ot-gio-utils.h

index a3c1401db70224ca39f0f24233c0392e391b3999..65173ffed41ef4823e61983a6c9e2ec7963d23ed 100644 (file)
@@ -1827,7 +1827,7 @@ _ostree_sysroot_write_deployments_internal (OstreeSysroot     *self,
     {
       int new_bootversion = self->bootversion ? 0 : 1;
       glnx_unref_object OstreeBootloader *bootloader = NULL;
-      g_autoptr(GFile) new_loader_entries_dir = NULL;
+      g_autofree char* new_loader_entries_dir = NULL;
       glnx_unref_object OstreeRepo *repo = NULL;
       gboolean show_osname = FALSE;
 
@@ -1848,11 +1848,11 @@ _ostree_sysroot_write_deployments_internal (OstreeSysroot     *self,
       if (!_ostree_sysroot_query_bootloader (self, &bootloader, cancellable, error))
         goto out;
 
-      new_loader_entries_dir = ot_gfile_resolve_path_printf (self->path, "boot/loader.%d/entries",
-                                                             new_bootversion);
-      if (!glnx_shutil_rm_rf_at (AT_FDCWD, gs_file_get_path_cached (new_loader_entries_dir), cancellable, error))
+      new_loader_entries_dir = g_strdup_printf ("boot/loader.%d/entries", new_bootversion);
+      if (!glnx_shutil_rm_rf_at (self->sysroot_fd, new_loader_entries_dir, cancellable, error))
         goto out;
-      if (!ot_util_ensure_directory_and_fsync (new_loader_entries_dir, cancellable, error))
+      if (!glnx_shutil_mkdir_p_at (self->sysroot_fd, new_loader_entries_dir, 0755,
+                                   cancellable, error))
         goto out;
       
       /* Need the repo to try and extract the versions for deployments.
index 06bf1a27c4165b1a09adf8451c54ff9ab6338685..ba21b467f6804a2b8f369bea4d753b63f93a7d90 100644 (file)
@@ -314,73 +314,6 @@ ot_gfile_ensure_unlinked (GFile         *path,
   return TRUE;
 }
 
-/**
- * ot_util_ensure_directory_and_fsync:
- * @dir: Path to a directory
- * @cancellable: Cancellable
- * @error: Error
- *
- * Create @dir (and all intermediate parent directories), ensuring
- * that all entries are on disk.
- */
-gboolean
-ot_util_ensure_directory_and_fsync (GFile         *dir,
-                                    GCancellable  *cancellable,
-                                    GError       **error)
-{
-  gboolean ret = FALSE;
-  glnx_fd_close int parentfd = -1;
-  const char *basename = glnx_basename (gs_file_get_path_cached (dir));
-  g_autoptr(GFile) parent = g_file_get_parent (dir);
-  
- again:
-  parentfd = open (gs_file_get_path_cached (parent),
-                   O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_CLOEXEC);
-  if (parentfd == -1)
-    {
-      if (errno == ENOENT)
-        {
-          if (!ot_util_ensure_directory_and_fsync (parent, cancellable, error))
-            goto out;
-          goto again;
-        }
-      else
-        {
-          int errsv = errno;
-          g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errsv),
-                       "opendir: %s", g_strerror (errsv));
-          goto out;
-        }
-    }
-  
-  if (mkdirat (parentfd, basename, 0777) == -1)
-    {
-      if (errno == EEXIST)
-        {
-          ;
-        }
-      else
-        {
-          int errsv = errno;
-          g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errsv),
-                       "mkdirat: %s", g_strerror (errsv));
-          goto out;
-        }
-    }
-
-  if (fsync (parentfd) == -1)
-    {
-      int errsv = errno;
-      g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errsv),
-                   "fsync: %s", g_strerror (errsv));
-      goto out;
-    }
-
-  ret = TRUE;
- out:
-  return ret;
-}
-
 #if !GLIB_CHECK_VERSION(2, 44, 0)
 
 gboolean
index 0750a5b47218693a3ececd703bc6d75bc13e9b92..34040238211c32e685e9506ac29865fcbfebc72c 100644 (file)
@@ -85,10 +85,6 @@ gboolean ot_gfile_ensure_unlinked (GFile         *path,
                                    GCancellable  *cancellable,
                                    GError       **error);
 
-gboolean ot_util_ensure_directory_and_fsync (GFile         *dir,
-                                             GCancellable  *cancellable,
-                                             GError       **error);
-
 #if !GLIB_CHECK_VERSION(2, 44, 0)
 gboolean
 ot_file_enumerator_iterate (GFileEnumerator  *direnum,